<%@ include file="includeTop.jsp"%>
<html>
<head>
<title></title>
<%@ include file="includeTop_head.jsp"%>
<!-- Skin CSS file -->
<link rel="stylesheet" type="text/css"
	href="http://yui.yahooapis.com/2.8.1/build/assets/skins/sam/skin.css">
<!-- Utility Dependencies -->
<script
	src="http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script
	src="http://yui.yahooapis.com/2.8.1/build/element/element-min.js"></script>
<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
<script
	src="http://yui.yahooapis.com/2.8.1/build/container/container_core-min.js"></script>
<script src="http://yui.yahooapis.com/2.8.1/build/menu/menu-min.js"></script>
<script src="http://yui.yahooapis.com/2.8.1/build/button/button-min.js"></script>
<!-- Source file for Rich Text Editor-->
<script src="http://yui.yahooapis.com/2.8.1/build/editor/editor-min.js"></script>
</head>
<body class="yui-skin-sam">
<table width="100%" align="center" style="padding: 0; margin: 0"
	border=0>
	<tr>
		<td align="center" colspan="3"><%@ include file="user_status.jsp"%></td>
	</tr>
	<tr>
		<td align="center"><%@ include file="title.jsp"%></td>
		<td align="center"><%@ include file="cartbar.jsp"%></td>
	</tr>
	<tr>
		<td align="left" colspan="3">
		<table align="left" border=0>
			<tr>
				<td width="197" valign="top"><%@ include file="admin_left.jsp"%></td>
				<td valign="top" width="100%">
				<form id="form" action="<c:url value="/admin/saveproduct.do"/>"
					method="post"><spring:bind path="product.productId">
					<input type="hidden" name="<c:out value="${status.expression}"/>"
						value="<c:out value="${status.value}"/>" />
				</spring:bind>
				<TABLE class="rededit" border=0 cellpadding=3 cellspacing=1
					width="100%">
					<TR>
						<TD colspan=2><FONT size=4><B>Add/Update Product</B></FONT></TD>
					</TR>
					<TR>
						<TD align="right">Category:</TD>
						<TD><spring:bind path="product.categoryId">
							<select name="<c:out value="${status.expression}"/>">
								<c:forEach var="category" items="${categories}">
									<option
										<c:if test="${category.id == product.categoryId}">selected</c:if>
										value="<c:out value="${category.id}"/>"><c:out
										value="${category.name}" /></option>

									<c:forEach var="category1"
										items="${category.childrenCategories}">
										<option
											<c:if test="${category1.id == curCategoryId}">selected</c:if>
											value="<c:out value="${category1.id}"/>">--<c:out
											value="${category1.name}" /></option>
									</c:forEach>
								</c:forEach>
							</select>
						</spring:bind></TD>
					</TR>
					<tr>
						<td align="right">Product Name:</td>
						<td><spring:bind path="product.name">
							<input type="text" size="97"
								name="<c:out value="${status.expression}"/>"
								value="<c:out value="${status.value}"/>" />
						</spring:bind></td>
					</tr>
					<tr>
						<td align="right">Product Number:</td>
						<td><spring:bind path="product.productNo">
							<input type="text" name="<c:out value="${status.expression}"/>"
								value="<c:out value="${status.value}"/>" />
						</spring:bind></td>
					</tr>
					<tr>
						<td align="right">Unit Price(Market):</td>
						<td><spring:bind path="product.unitPrice">
			AU $<input type="text" name="<c:out value="${status.expression}"/>"
								size="16" value="<c:out value="${status.value}"/>" />
						</spring:bind></td>
					</tr>
					<tr>
						<td align="right">Unit Price(Cur):</td>
						<td><spring:bind path="product.unitPriceCur">
			AU $<input type="text" name="<c:out value="${status.expression}"/>"
								size="16" value="<c:out value="${status.value}"/>" />
						</spring:bind></td>
					</tr>
					<tr>
						<td align="right">Quantity:</td>
						<td><spring:bind path="product.amount">
							<input type="text" name="<c:out value="${status.expression}"/>"
								value="<c:out value="${status.value}"/>" />
						</spring:bind></td>
					</tr>
					<tr>
						<td align="right">Available Quantity:</td>
						<td><spring:bind path="product.curAmount">
							<input type="text" name="<c:out value="${status.expression}"/>"
								value="<c:out value="${status.value}"/>" />
						</spring:bind></td>
					</tr>
					<tr>
						<td valign="top" align="right">Product Image:</td>
						<td>
						<table>
							<tr>
								<c:forEach var="imgUrl" items="${product.imgUrls}">
									<td><img src="<c:out value="${imgUrl}" />" width="100"
										height="100" /><br></br>
									<input type="button" value="Delete" /></td>
								</c:forEach>
							</tr>
						</table>
						<a
							href="<c:url value="/admin/uploadproductimg.do?productId=${product.productId}"/>">
						<input type="button" value="Add New Image"></a></td>
					</tr>
					<tr>
						<td valign="top" align="right">Product Detail</td>
						<td><spring:bind path="product.description">
							<textarea id="description" rows=90 cols="500"
								name="<c:out value="${status.expression}"/>"><c:out
								value="${status.value}" /></textarea>
						</spring:bind></td>
					</tr>
					<script>
	var myEditor = new YAHOO.widget.Editor('description', {
	    height: '600px',
	    width: '800px',
	    dompath: true, //Turns on the bar at the bottom
	    animate: true //Animates the opening, closing and moving of Editor windows
	});
	myEditor.render();
	//Inside an event handler after the Editor is rendered
	YAHOO.util.Event.on('saveText', 'click', function() {
	    //Put the HTML back into the text area
	    myEditor.saveHTML();
	 
	    //The var html will now have the contents of the textarea
	    var html = myEditor.get('element').value;
	    //alert(html);
	    $("#description").get(0).value = html;
	    $("#form").get(0).submit();
	});
	
	</script>
					<tr>
						<td colspan="5" align="center"><input id="saveText"
							type="button" value="Submit" /></td>
					</tr>

				</TABLE>
				</form>

				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td align="center" colspan="3"><%@ include
			file="includeBottom.jsp"%></td>
	</tr>
</table>
</body>
</html>

